define(["app", "js/services/BaseService"], function (app) {

    var deps = ["$http", "BaseService"];

    var headers = {
        "Content-Type": "application/x-www-form-urlencoded;charset=utf-8"
    };

    function fileResource ($http, BaseService) {
        return {
            upload: function (file) {
                var fd = new FormData();
                fd.append('files', file);
                return $http({
                    method: 'POST',
                    url: baseServices_restfulUrl + "/fileUpload/upload.json",
                    data: fd,
                    headers: {'Content-Type': undefined},
                    transformRequest: angular.identity
                });
            },
            getFiles: function (fileId) {
                return $http.post(baseServices_restfulUrl + '/fileUpload/getFile.json', {fileId: fileId}, {headers: headers});
            },
            delFiles: function (fileId) {
                return $http.post(baseServices_restfulUrl + '/fileUpload/delete.json', {fileId: fileId}, {headers: headers});
            },


            // savePic: function (obj) { //保存图片并获取picId
            //     return $http.post(BaseService.restfulUrl + "TempFileUploadController/savePic", JSON.stringify(obj));
            // },
            // savePics: function (obj) { //保存图片列表并获取picIds
            //     return $http.post(BaseService.restfulUrl + "TempFileUploadController/savePics", JSON.stringify(obj));
            // },
            //
            // downFile : function(Id){
            // 	return $http.get("restful/FileService/downFile", {
            //        params: {
            //        	fileId: Id
            //        }
            //    });
            // },
            // getPic: function (picId) {
            //     return $http.get(baseServices_restfulUrl + "PictureService/getPicById", {
            //         params: {
            //             picId: picId
            //         }
            //     });
            // }

        };
    }

    fileResource.$inject = deps;
    app.lazy.factory("FileResource", fileResource);
});
